package com.terren.spider.util.common;

import java.util.HashMap;
import java.util.Map;

/**
 * 类说明：URL参数解析
 * 
 * @author 
 * @version 
 */
public class URLAnalysis {
	private Map<String, String> paramMap = new HashMap<String, String>();

	public void analysis(String url) {
		paramMap.clear();
		if (!"".equals(url)) {// 如果URL不是空字符串
			url = url.substring(url.indexOf('?') + 1);
			String paramaters[] = url.split("&");
			for (String param : paramaters) {
				String values[] = param.split("=");
				if(values.length==1){
					paramMap.put(values[0], "");
				}else{
					paramMap.put(values[0], values[1]);
				}
			}
		}
	}

	public String getParam(String name) {
		return paramMap.get(name);
	}
}

